#include <bits/stdc++.h>
#ifdef dbg
#define D(...) fprintf(stderr, __VA_ARGS__)
#define DD(...) D(#__VA_ARGS__ " = "), debug_helper::debug(__VA_ARGS__), D("\n")
#include "C:\Users\wsyear\Desktop\OI\templates\debug.hpp"
#else
#define D(...) ((void)0)
#define DD(...) ((void)0)
#endif
#define rep(i, j, k) for (int i = (j); i <= (k); ++i)
#define per(i, j, k) for (int i = (j); i >= (k); --i)
#define SZ(v) int((v).size())
#define ALL(v) (v).begin(),(v).end()
#define fi first
#define se second
#define gc getchar
#define pc putchar
using ll = long long;
using pii = std::pair<int, int>;
using pll = std::pair<ll, ll>;

using namespace std;

template <class T = int> T read() {
  T x = 0; bool f = 0; char ch = gc();
  while (!isdigit(ch)) f = ch == '-', ch = gc();
  while (isdigit(ch)) x = (x << 3) + (x << 1) + (ch ^ 48), ch = gc();
  return f ? -x: x;
}
template <class T> void write(T x) {
  if (x >= 0) { if (x > 9) write(x / 10); pc(x % 10 + 48); }
  else { pc('-'); if (x < -9) write(-x / 10); pc(48 - x % 10); }
}

const int N = 1000010;

int n, fa[N], vis[N];
vector<int> e[N], tmp;
queue<int> q;

int main() {
  freopen("choice.in", "r", stdin);
  freopen("choice.out", "w", stdout);
  n = read();
  rep (i, 1, n - 1) {
    int u = read(), v = read();
    e[u].emplace_back(v);
    e[v].emplace_back(u);
  }
  q.push(1);
  while (!q.empty()) {
    int u = q.front();
    q.pop();
    for (int v : e[u]) {
      if (v == fa[u]) continue;
      fa[v] = u, q.push(v);
    }
  }
  vis[0] = 1;
  rep (i, 1, n) {
    tmp.clear();
    int u = i;
    while (!vis[u]) tmp.emplace_back(u), u = fa[u];
    reverse(ALL(tmp));
    for (int x : tmp) write(x), pc(32), vis[x] = 1;
  }
}